package drp.snowbell.cfg.init;

import java.util.Collection;

import drp.snowbell.cfg.ModuleConfig;
import drp.snowbell.exception.CatchException;
import drp.snowbell.module.ModuleManager;


public class Initializer {
	private static Initializer instance;

	public static Initializer getInstance() {
		if (instance == null) {
			instance = new Initializer();
		}
		return instance;
	}

	public void init() {
		ModuleLoader loader = ModuleLoader.getInstance();
		Collection<ModuleConfig> moduleList = loader.getModuleConfigList();
		for (ModuleConfig mc : moduleList) {
			boolean result = ModuleManager.register(mc);
			if (result == false) {
				CatchException.debug(Initializer.class, "register " + mc.getName() + " failed");
			} else {
				CatchException.debug(Initializer.class, "register " + mc.getName() + " success");
			}
		}
	}

}
